package com.example.teemor.es_demo.config;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

/**
 * 日志管理配置属性类
 * 用于读取application.yml中的日志管理相关配置
 */
@Data
@Component
@ConfigurationProperties(prefix = "app.log-management")
public class LogManagementProperties {
    
    /**
     * Kafka相关配置
     */
    private Kafka kafka = new Kafka();
    
    /**
     * ClickHouse相关配置
     */
    private ClickHouse clickhouse = new ClickHouse();
    
    /**
     * 埋点追踪配置
     */
    private Tracking tracking = new Tracking();
    
    @Data
    public static class Kafka {
        /**
         * Topic配置
         */
        private Topics topics = new Topics();
        
        /**
         * 批处理配置
         */
        private Batch batch = new Batch();
        
        @Data
        public static class Topics {
            /**
             * 服务日志Topic
             */
            private String serviceLog = "service-logs";
            
            /**
             * 用户行为Topic
             */
            private String userBehavior = "user-behaviors";
        }
        
        @Data
        public static class Batch {
            /**
             * 服务日志批处理大小
             */
            private int serviceLogSize = 100;
            
            /**
             * 服务日志批处理超时时间（毫秒）
             */
            private long serviceLogTimeout = 5000;
            
            /**
             * 用户行为批处理大小
             */
            private int userBehaviorSize = 50;
            
            /**
             * 用户行为批处理超时时间（毫秒）
             */
            private long userBehaviorTimeout = 3000;
        }
    }
    
    @Data
    public static class ClickHouse {
        /**
         * 批处理配置
         */
        private Batch batch = new Batch();
        
        /**
         * 表名配置
         */
        private Tables tables = new Tables();
        
        @Data
        public static class Batch {
            /**
             * 批处理大小
             */
            private int size = 1000;
            
            /**
             * 批处理超时时间（毫秒）
             */
            private long timeout = 10000;
        }
        
        @Data
        public static class Tables {
            /**
             * 服务日志表名
             */
            private String serviceLog = "service_logs";
            
            /**
             * 用户行为表名
             */
            private String userBehavior = "user_behaviors";
        }
    }
    
    @Data
    public static class Tracking {
        /**
         * 是否启用埋点追踪
         */
        private boolean enabled = true;
        
        /**
         * 是否开启调试模式
         */
        private boolean debugMode = false;
    }
}